<?php
	$url = base64_decode($_GET['u']);
	//echo $url;
	$file = "c/".hash("md5",$url);
	if(!file_exists($file)){
		
		require_once 'simple_html_dom.php';
		$html = file_get_html($url);
		//echo $html;		
		foreach($html->find('a') as $element){
			$a = base64_encode($element->href);
			$element->href = "index.php?a=$a";
		}
		
		//if($_SERVER["REQUEST_METHOD"]=="POST"){
		if(preg_match("/searchp/",$a)){
			//search
			$gets = $html->find("table[class=GridViewStyle]");
		}
		else if($a=="http://www.taobangwang.cn/"){
			//首页
			
		}
		else{ //列表
			//echo 'other';
			$gets = $html->find("div[id=Category]");
			$gets = array_merge($gets,$html->find("div[class=listall]"));
			$gets = array_merge($gets,$html->find("table[class=GridViewStyle]"));
		}
		foreach($gets as $g) {
			$s = $s.$g;
		}
		if(strlen($s)>200){
			echo $s;
			file_put_contents($file,$s);
		}		
	}
	else
		echo file_get_contents($file);
?>